//
//  ScanQRViewController.m
//  AlinkDemo
//
//  Created by Vincent on 2017/10/26.
//  Copyright © 2017年 aliyun. All rights reserved.
//

#import "ScanQRViewController.h"
#import <EquesBusiness/YKBusinessFramework.h>
#import "Constant.h"
#import <SystemConfiguration/CaptiveNetwork.h>
#import <AlinkSDK/AlinkAccount.h>

@interface ScanQRViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *qrImageView;

@end

@implementation ScanQRViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    NSDictionary *session =  [[AlinkAccount sharedInstance] currentSession];
    NSString *userName = session[@"ak_account"];
    if (userName) {
        self.qrImageView.image = [YKBusinessFramework equesCreateQRCodeNewWithWifiSsid:self.SSID wifiPw:self.wifipwd username:userName keyId:KEYID role:EquesElse imageSize:480];
    }

}
#pragma mark - wifi

- (id)fetchSSIDInfo {
    NSArray *ifs = (__bridge_transfer id)CNCopySupportedInterfaces();
    NSLog(@"Supported interfaces: %@", ifs);
    NSDictionary *info = nil;
    NSString *ssid = nil;
    for (NSString *ifnam in ifs) {
        info = (__bridge_transfer id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam);
        NSLog(@"%@ => %@", ifnam, info);
        if (info && [info count]) {
            if ([info objectForKey:@"SSID"]) {
                ssid = [info objectForKey:@"SSID"];
            }
            break;
        }
    }
    //return info;
    return ssid;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
